package graph.day13;

import java.util.Arrays;

public class ChooseSort {

    public static void choose(int[] arr) {
        for (int i = arr.length - 1; i > 0; i--) {
            int max = i;
            for (int j = 0; j < i; j++) {
                if (arr[j] > arr[max]) {
                    max = j;
                }
            }
            if (max != i) {
                int temp = arr[i];
                arr[i] = arr[max];
                arr[max] = temp;
            }
        }
    }

    public static void main(String[] args) {
        int[] arr = {5, 4, 3, 2, 1};
        System.out.println(Arrays.toString(arr));
        choose(arr);
        System.out.println(Arrays.toString(arr));
    }
}
